home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Snippets / Blasto-C / DirectPlotColorIcon.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-27  |  2.9 KB  |  80 lines  |  [TEXT/MPS ]

  1. /*
  2.     11-11-92 • BRS changed things from short to long, to fix bug with THINK C compiler.
  3.  
  4.  
  5.  
  6. */
  7. #include "DirectScreen.h"
  8.  
  9. void DirectPlotColorIcon(long *colorIconPtr, PixMapHandle screenPixMap, short row, short col)
  10. /*
  11.     Draws a color icon image directly to the pixMap passed.
  12.     colorIconPtr = pointer to the image data for a color icon
  13.     screenPixMap = handle to the pixMap for the screen we're writing on
  14.     row, col      = location of the top left corner of the icon in the 
  15.                     pixMap's coordinate system; 
  16.                     since we know the icon is 32 by 32, 
  17.                     the other coordinates are unnecessary.
  18. */
  19. {
  20.     register long *screenMemPtr;        // Pointer to video memory
  21.     register long numRowsToCopy;        // Rows we are going to copy
  22.     register long stripRowBytes;        // To clear high bit of rowbytes
  23.     register long rowLongsOffset;        // rowBytes converted to long
  24.              char  mmuMode;                // 32-bit mode required
  25.              Rect  cursRect;            // rectangle for shield cursor call
  26.              Point cursOffset;            // 0,0 to indicate rect is in global coordinates
  27.              
  28.     /* High bit of pixMap rowBytes must be cleared. */
  29.     stripRowBytes = (0x7FFF & (**screenPixMap).rowBytes);
  30.  
  31.     /* We must strip the high byte of the address of the color icon, which, if we're in
  32.         24-bit mode, may be garbage when we go to 32-bit mode to access video memory. */
  33.     colorIconPtr = (long *)StripAddress(colorIconPtr);
  34.     
  35.     /* Calculate the address of the first byte of the destination. */
  36. //    screenMemPtr = (long *)(GetPixBaseAddr(screenPixMap) + (stripRowBytes * row) + col);
  37. // Avoid the trap overhead of GetPixBaseAddr - which is also known to cause problems
  38.     screenMemPtr = (long *)((**screenPixMap).baseAddr + (stripRowBytes * row) + col);
  39.  
  40.     /* call shield cursor to maintain compatibility with all displays */
  41.     /* This rectangle should be a parameter, but this was added to late */
  42.     cursOffset.h = 0;
  43.     cursOffset.v = 0;
  44.     cursRect.top = row;
  45.     cursRect.left = col;
  46.     cursRect.bottom = row + 32;
  47.     cursRect.right = col + 32;
  48.     ShieldCursor(&cursRect,cursOffset);
  49.     
  50.     /* Change to 32-bit addressing mode to access video memory. The previous addressing mode 
  51.         is returned in mmuMode for restoring later. */
  52.     mmuMode = true32b;
  53.     SwapMMUMode(&mmuMode);
  54.     
  55.     numRowsToCopy = 32;                        /* Color icons have 32 rows. */
  56.     
  57.     /* Calculate the long word offset from the end of one row of the color icon on the screen's 
  58.         pixMap to the first byte of the icon in the next row. */
  59.     rowLongsOffset = (stripRowBytes/4) - 8;
  60.     
  61.     /* Draw the color icon directly to the screen. */
  62.     do {
  63.             *screenMemPtr++ = *colorIconPtr++;
  64.             *screenMemPtr++ = *colorIconPtr++;
  65.             *screenMemPtr++ = *colorIconPtr++;
  66.             *screenMemPtr++ = *colorIconPtr++;
  67.             *screenMemPtr++ = *colorIconPtr++;
  68.             *screenMemPtr++ = *colorIconPtr++;
  69.             *screenMemPtr++ = *colorIconPtr++;
  70.             *screenMemPtr++ = *colorIconPtr++;
  71.     
  72.         /* Bump to start of next row. */
  73.             screenMemPtr += rowLongsOffset;
  74.     } while(--numRowsToCopy);
  75.     
  76.     
  77.     SwapMMUMode(&mmuMode);        /* Restore addressing mode back to what it was. */
  78.     ShowCursor();
  79. }
  80.